<template>
    <div>
        home
        <ol>
            <li>1111111111</li>
        </ol>
        <button @click="goSetting">setting</button>
        <button @click="openSet">open setting</button>
        <button @click="openTest">open test</button>
        <div>
            {{ testCount }}
        </div>
        <button @click="addCount">add</button>
    </div>
</template>

<script setup lang="ts">
import { useRouter } from 'vue-router'
import { settingStore } from '@renderer/store/setStore'
import { storeToRefs } from 'pinia'
import { getMoHuList } from '@renderer/api/index'
const { ipcRenderer } = require('electron')
const setStoreData = settingStore()
const { testCount } = storeToRefs(setStoreData)

const router = useRouter()
const goSetting = () => {
    router.push('/setting')
}
const openSet = () => {
    let api: any = window.api
    const obj = {
        url: '/setting',
        name: 'setWindow',
        title: '设置'
    }
    api.newOpen(obj)
}
const openTest = () => {
    let api: any = window.api
    const obj = {
        url: '/test',
        name: 'testWindow',
        title: '测试'
    }
    api.newOpen(obj)
}
const addCount = () => {
    setStoreData.addCount()
    ipcRenderer.send('update-storage', JSON.stringify(setStoreData.$state), 'setStoreData')
}
const getData = async () => {
    const obj = {
        return: 'json',
        id: 'img1',
        num: 5
    }
    const res = await getMoHuList(obj)
    console.log(res)
}
getData()
</script>

<style scoped lang="scss">
ol {
    background-color: $primary;
    @include mixin.box_shadow();
}
</style>